package com.chenwut.test1;

import java.util.Scanner;

public class Main4 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();  // 测试样例数量
        for (int i = 0; i < t; i++) {
            int n = sc.nextInt();  // 密码锁的位数
            int[] S = new int[n];  // 当前密码锁的状态
            for (int j = 0; j < n; j++) {
                S[j] = sc.nextInt();
            }
            for (int j = 0; j < n; j++) {
                int k = sc.nextInt();  // 操作步数
                String s = sc.next();  // 操作类型
                for (int l = 0; l < k; l++) {
                    if (s.charAt(l) == 'U') {
                        S[j] = (S[j] + 9) % 10;
                    } else if (s.charAt(l) == 'D') {
                        S[j] = (S[j] + 1) % 10;
                    }
                }
            }
            for (int j = 0; j < n; j++) {
                System.out.print(S[j] + " ");
            }
            System.out.println();
        }
    }
}